package cn.wolfcode.trip.app.web.controller;

import cn.wolfcode.trip.base.domain.AddComment;
import cn.wolfcode.trip.base.query.AddCommentQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IAddCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/addComments")
public class AddCommentController {
    @Autowired
    private IAddCommentService iAddCommentService;
    //获得子评论内容
    @RequestMapping("/{commentId}")
    public Object getAddComment(@PathVariable Long commentId) {
        return iAddCommentService.getAdd(commentId);
    }
    //获得子评论数量
    @GetMapping("/{commentId}/count")
    public Object getCount(@PathVariable Long commentId) {
        int count = iAddCommentService.getCount(commentId);
        Map<String,Object> map = new HashMap<>();
        map.put("counts",count);
        return map;
    }
    //获得子评论点赞数量
    //@GetMapping("/{commentId}/count")

    //查询评论我的
    @GetMapping
    @ResponseBody
    public Object commentMe(AddCommentQueryObject qo){
        return iAddCommentService.commentMeList(qo);
    }

}
